home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / musicmixer / src / mixer / mixerdialog.java
Encoding:
Java Source  |  2000-06-23  |  1.6 KB  |  56 lines

  1. /*
  2.  * QuickTime for Java SDK Sample Code
  3.  
  4.    Usage subject to restrictions in SDK License Agreement
  5.  * Copyright: © 1996-1999 Apple Computer, Inc.
  6.  
  7.  */
  8. package mixer;
  9.  
  10. import java.awt.*;
  11. import javax.swing.*;
  12.  
  13. import quicktime.*;
  14. import quicktime.app.audio.*;
  15.  
  16. /** This is the main display for the Mixer program.  This is how we present all of
  17.  *  our mixer tools.
  18.  */
  19. public class MixerDialog extends JDialog implements SwingConstants {
  20.     /** The frame that owns this dialog box. */
  21.     public static Frame parentFrame;
  22.     
  23.     /** The default name that will show in the dialog's title area. */
  24.     public static String defaultName;
  25.     
  26.     /** The constructor takes any component you create to represent the mixer, and
  27.      *  displays it in a dialog box.
  28.      *  @param mixer the JComponent that contains your mixer controls.
  29.      */
  30.     public MixerDialog (JComponent mixer) throws QTException {
  31.         super (parentFrame, defaultName, false);
  32.         
  33.         Container cp = getContentPane();
  34.         cp.setLayout(new GridBagLayout());
  35.         GridBagConstraints cons = new GridBagConstraints();
  36.         cons.gridx = 0;
  37.         cons.gridy = 0;
  38.         cons.weightx = 0.0F;
  39.         cons.weighty = 0.0F;
  40.         cons.fill = GridBagConstraints.NONE;
  41.         cons.anchor = GridBagConstraints.CENTER;
  42.         cp.add (mixer, cons);
  43.         pack();
  44.  
  45.         // The next two lines are very specific to our code.  Swing wasn't making a default
  46.         // size quite big enough, so we just set a lower limit.
  47.         Dimension d = mixer.getPreferredSize();
  48.         mixer.setPreferredSize(new Dimension(d.width, d.height < 300 ? 300 : d.height));
  49.  
  50.         Rectangle loc = parentFrame.getBounds();
  51.         setLocation(loc.x, loc.height + loc.y);
  52.         pack();
  53.         show();
  54.     }
  55. }
  56.